import socket
server_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
server_socket.bind(('localhost',8888))
server_socket.listen(1)
conn,addr = server_socket.accept()
print(f"客户端已连接：{addr}")
while True:
    data = conn.recv(1024)
    if not data:
        break
    print(f"收到客户端{addr[0]}:{addr[1]}消息：{data.decode()}")
    conn.sendall(data)

conn.close()
server_socket.close()
print("连接已关闭")